<?php
namespace app\beautiful\model\member;
use app\common\model\CommonModel;

class MemberIntegralModel extends CommonModel{
    protected  $name = 'beautiful_member_integral';
    protected  $pk   = 'member_integral_id';
    
    
     public function getIntegralSumByMemberId($memberIds){
       $where = [
            ['member_id','IN',$memberIds],
       ];
       $now_time = time();
       $where [] =  ['expire_time','>',$now_time];
       
       $datas = $this->field('member_id,SUM(remain_integral) AS integral')->where($where)->group('member_id')->select();
       $return = [];
       foreach($datas as $val){
           $return[$val['member_id']] = $val['integral'];
       }
       return $return;
    }
}
